import { reqGetSearchInfo } from "@/api";

const state = {
  searchList: {},
};
// 修改数据
const mutations = {
  GETSEARCHLIST(state, searchlist) {
    state.searchList = searchlist;
  },
};
// 业务逻辑
const actions = {
  async getSearchList({ state, dispatch, commit }, searchParams) {
    let result = await reqGetSearchInfo(searchParams);
    if (result.code == 200) {
      commit("GETSEARCHLIST", result.data);
    }
  },
};
// 计算属性,在项目中，为了简化数据
const getters = {
  goodsList() {
    return state.searchList.goodsList || [];
  },
  trademarkList(state) {
    return state.searchList.trademarkList || [];
  },
  attrsList(state) {
    return state.searchList.attrsList || [];
  },
};

export default {
  state,
  mutations,
  actions,
  getters,
};
